package javango.db;

import java.io.Serializable;
import java.util.Map;

/**
 * Generic interface for database operations for a given model.
 * 
 *  Managers are not intended to replace other data access methods,  instead they are intended to facilitate creating generic views
 *  and the javango administration interface.  They are a totally optional piece and are not required.
 *  
 * @author johns
 *
 * @param <T>
 */
public interface Manager<T> {

	QuerySet<T> all() throws ManagerException;
	
	QuerySet<T> filter(Object params) throws ManagerException;
	QuerySet<T> filter(Map<String, Object> params) throws ManagerException;

	QuerySet<T> filter(String property, Object value) throws ManagerException;
	QuerySet<T> filterByProperty(String propertyA, String propertyB) throws ManagerException;
	
	T get(Serializable pk) throws ManagerException;
	T save(T object) throws ManagerException;
	void delete(T object) throws ManagerException;
	
	Serializable getPk(T object) throws ManagerException;
	
	// TODO Class Array or single class???  how does this affect the getPk method??  ie if this is an array getPk should probably return Serializable[]
	Class[] getPkClass() throws ManagerException;
	// TODO String[] or String???
	public String getPkProperty() throws ManagerException;
}
